package com.yizhubao.app.base;

import android.graphics.Typeface;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.yizhubao.app.R;

import butterknife.BindView;

/**
 * 创建人: PACY
 * 创建时间: 6/4/21 10:11 AM
 * 邮箱: pengwwe457621023@qq.com
 * 类描述: toolbaractivity基类
 */
public abstract class BaseActivityToolBar extends BaseActivity{
    @BindView(R.id.base_left_icon)
    ImageView leftIcon_iv;
    @BindView(R.id.base_left_text)
    TextView leftText_tv;
    @BindView(R.id.base_title)
    TextView titleText_tv;
    @BindView(R.id.base_right_icon)
    ImageView rightIcon_iv;
    @BindView(R.id.base_right_text)
    TextView rightText_tv;
    @BindView(R.id.view)
    View view;

    /**
     * 设置标题
     *
     * @param title
     */
    public void setTitle(String title) {
        titleText_tv.setText(title);
        titleText_tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        titleText_tv.setVisibility(View.VISIBLE);
        ImmersionBar.setStatusBarView(this, view);
        leftIcon_iv.setOnClickListener(view -> finish());
    }

    /**
     * 设置左边icon
     *
     * @param leftIconResources
     * @param title
     */
    public void setTitleOnLeftIcon(int leftIconResources, String title) {
        leftIcon_iv.setVisibility(View.VISIBLE);
        leftIcon_iv.setImageResource(leftIconResources);
        setTitle(title);
    }

    /**
     * 设置左边icon
     *
     * @param title
     */
    public void setTitleOnLeftIcon(String title) {
        leftIcon_iv.setVisibility(View.VISIBLE);
        setTitle(title);
    }


    /**
     * 设置左边文字
     *
     * @param leftText
     * @param title
     */
    public void setTitleOnLeftText(String leftText, String title) {
        leftText_tv.setVisibility(View.VISIBLE);
        leftText_tv.setText(leftText);
        setTitle(title);
    }

    /**
     * 设置右边icon
     *
     * @param rightIconResouces
     * @param title
     */
    public void setTitleRightIcon(int rightIconResouces, String title) {
        rightIcon_iv.setVisibility(View.VISIBLE);
        rightIcon_iv.setImageResource(rightIconResouces);
        setTitle(title);
    }

    /**
     * 设置右边文字
     *
     * @param rightText
     * @param title
     */
    public void setTitleOnRightText(String rightText, String title) {
        rightText_tv.setVisibility(View.VISIBLE);
        rightText_tv.setText(rightText);
        setTitle(title);
    }

    /**
     * 设置右边文字
     *
     * @param rightText
     * @param title
     */
    public void setTitleOnRightText(int leftIconResources,String rightText, String title) {
        leftIcon_iv.setVisibility(View.VISIBLE);
        leftIcon_iv.setImageResource(leftIconResources);
        rightText_tv.setVisibility(View.VISIBLE);
        rightText_tv.setText(rightText);
        setTitle(title);
    }
}
